//package didactic;
//
//import javax.sql.DataSource;
//
//import org.junit.After;
//import org.junit.Before;
//import org.junit.Test;
//import org.mb.criteria.Criteria;
//import org.mb.datasource.HsqldbDataSourceFactory;
//import org.mb.mapper.DataMapper;
//import org.mb.record.Entity;
//import org.mb.session.SessionFactory;
//import org.mb.test.EntityTest2;
//import org.mb.test.ent.Dog;
//
//import static org.junit.Assert.*;
//
//public class Didactic1 {
//	static {
//		new EntityTest2();
//	}
//
//	@Before
//	public void before() {
//		SessionFactory.getSession().open();
//
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE A");
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE B");
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE AB");
//
//		DataMapper.executeDDL(
//		/**/"CREATE TABLE AB (" +
//		/**/"ID_AB BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100) PRIMARY KEY," +
//		/**/"ID_A INTEGER," +
//		/**/"ID_B INTEGER)"
//		/**/);
//		DataMapper.executeDDL(
//		/**/"CREATE TABLE A(" +
//		/**/"ID_A INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) PRIMARY KEY)"
//		/**/);
//		DataMapper.executeDDL(
//		/**/"CREATE TABLE B(" +
//		/**/"ID_B INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) PRIMARY KEY)"
//		/**/);
//		SessionFactory.getSession().commit();
//	}
//
//	@After
//	public void after() {
//		SessionFactory.getSession().open();
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE A");
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE B");
//		DataMapper.executeDDLIgnoringErrors("DROP TABLE AB");
//		SessionFactory.getSession().commit();
//	}
//
//	@Test
//	public void testname() throws Exception {
//
//		final DataSource ds = new HsqldbDataSourceFactory("jdbc:hsqldb:file:/home/mhoms/hsql8", "sa", null)
//				.getDataSource();
//		SessionFactory.setDataSource(ds);
//
//		SessionFactory.getSession().open();
//		try {
//
//			final Dog d = new Dog(null, "din", 12);
//
//			d.store();
//
//			final Dog d2 = Criteria.selectById(Dog.class, d.getId());
//
//			assertTrue(d == d2);
//
//			SessionFactory.getSession().commit();
//		} catch (final Exception e) {
//			SessionFactory.getSession().rollback();
//			throw e;
//		}
//	}
// }
